# -*- coding: utf-8 -*-
""" 
author: linpeifeng
date: 2021年12月03日17:09
"""
import yaml


def get_prefix(prefix, now_item):
    return ".".join([prefix, now_item]) if prefix else now_item


def list_dict_set(data: dict, result: list, prefix: str):
    for k, v in data.items():
        new_key = get_prefix(prefix, k)
        if isinstance(v, dict):
           list_dict_set(v, result, new_key)
        else:
           result.append({new_key, v})


if __name__ == "__main__":
    with open("sample.yaml", 'r') as f:
        content = yaml.load(f, yaml.FullLoader)
    result = []
    list_dict_set(content, result, '')
    print(result)













